package com.chat.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Utils {
	public static String getPwd(String pwd) {
		try {
			MessageDigest digest = MessageDigest.getInstance("md5");
			byte[] bs = digest.digest(pwd.getBytes());
			String hexString = "";
			for (byte b : bs) {
				int temp = b & 255;
				if (temp < 16 && temp >= 0) {
					hexString = hexString + "0" + Integer.toHexString(temp);
				} else {
					hexString = hexString + Integer.toHexString(temp);
				}
			}
			return hexString;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return "";
	}
	public static String getPassword(String pwd) {
		String leftPwd = "f218b81c0528bf69781ff8a7d6729171";
		String rightPwd = "f218b81c0528bf69781ff8a7d6729171";
		return getPwd(leftPwd + pwd + rightPwd);
	}
}